Characteristic analysis of epileptic brain network based on attention mechanism

Constructing an efficient and accurate epilepsy detection system is an urgent research task. In this paper, we developed an EEG-based multi-frequency multilayer brain network (MMBN) and an attentional mechanism based convolutional neural network (AM-CNN) model to study epilepsy detection. Specifically, based on the multi-frequency characteristics of the brain, we first use wavelet packet decomposition and reconstruction methods to divide the original EEG signals into eight frequency bands, and then construct MMBN through correlation analysis between brain regions, where each layer corresponds to a specific frequency band. The time, frequency and channel related information of EEG signals are mapped into the multilayer network topology. On this basis, a multi-branch AM-CNN model is designed, which completely matches the multilayer structure of the proposed brain network. The experimental results on public CHB-MIT datasets show that eight frequency bands divided in this work are all helpful for epilepsy detection, and the fusion of multi-frequency information can effectively decode the epileptic brain state, achieving accurate detection of epilepsy with an average accuracy of 99.75%, sensitivity of 99.43%, and specificity of 99.83%. All of these provide reliable technical solutions for EEG-based neurological disease detection, especially for epilepsy detection.

can be explored through network topology analysis. In general, the brain network can be inferred by setting the brain electrodes (channels) as nodes, and then the edges between the nodes can be determined by various related metrics. Moreover, multilayer network are the latest development of complex network theory [13][14][15] . The multilayer network has multiple layers and can describe different aspects of the studied system. The multilayer structure makes it possible to describe complex systems more comprehensively and accurately. Some successful applications of multilayer networks can be found in the fields of chemical systems 16 , EEG signal analysis 17,18 and traffic network analysis 19 .
The human brain has obvious multi-frequency characteristics. When multilayer network is introduced into brain research, spatiotemporal characteristics in each frequency band can be mapped into a single layer. MMBN considers the specific information of multiple frequency bands and can be used as an effective feature for epilepsy detection. However, it should be noted that in the analysis process, multilayer network are usually represented as a series of adjacency matrices. Each adjacency matrix corresponds to a single layer. In the face of such multidimensional samples, traditional classifiers, such as support vector machines, cannot be directly used for classification. As the most advanced theory in machine learning, deep learning [20][21][22][23] has received extensive and continuous attention. Specifically, deep learning is an end-to-end learning framework that can extract deeper internal representations from the input itself [24][25][26][27] . So far, deep learning has shown great potential in epilepsy research. For instance, Li et al. 28 proposed a deep learning method combining the fully convolution network and the long short-term memory (LSTM) to automatically detect epilepsy. Specifically, the full connection layer network and LSTM are used to extract EEG-based epileptic features and explore the inherent temporal correlation in EEG signals. Kemal et al. 29 developed a stacking ensemble method to detect epilepsy using five deep neural network (DNN) models. Gao et al. 30 used approximate entropy and recursive quantitative analysis to extract the features of EEG signals, and then establishes convolutional neural networks to detect epilepsy. Zhao et al. 31 developed a novel one-dimensional CNN model to detect epilepsy with raw EEG signals. The model used three convolution blocks including BN layer and dropout layer for feature extraction. Naseem et al. 32 employed a method integrating CWT and CNN to classify EEG data and detect seizures caused by epilepsy and brain tumors. The results show that the deep learning model is conducive to EEG classification and timely prediction of seizures to avoid damage caused by repeated seizures. Some researchers tried to add the attention mechanism module to the CNN model [33][34][35] . The attention mechanism introduces weight on the basis of the original model, and can help the new model focus on informative and important features.
Motivated by the above-described background and progress, we propose an epilepsy detection method combining multilayer brain network and deep learning. In detail, the EEG signals of each channel are decomposed into multiple frequency bands through wavelet packet decomposition and reconstruction. Then, constructing MMBN, where each layer is a spatiotemporal feature topology of EEG signals in a specific frequency band. Compared with single-layer network, this multilayer brain network integrates the information from multiple frequency bands, helping to provide a more comprehensive description of brain states. In addition, considering the strong ability of deep learning to learn structural features, we carefully developed a CNN model based on attention mechanism (AM-CNN) with MMBN as input. Through evaluation on the CHB-MIT dataset, this method achieved excellent performance with an accuracy of 99.75%. The results indicate that this study can effectively characterize the brain state during seizures, extract essential features for precise classification, and is expected to provide reference for other EEG signal based neurological disease detection. The overall structure of our work is shown in Fig. 1.

Results
MMBN analysis of brain-topological characteristic of epileptic. We randomly select eight subjects and calculate the measurement statistics of the MMBN obtained from the normal state and the seizure state respectively, and then t-test was performed on them. Four network measures are introduced, including average clustering coefficient C , clustering coefficient entropy E C , spectral radius R and graph energy E . These statistical measures are defined as the following equations: www.nature.com/scientificreports/ where N is the total number of nodes (channels) in the network, C(ν) means clustering coefficient of node ν , the mathematical expression is where t ν is the total number of closed triangles containing node ν , k ν is the degree of node ν , w νκ represents the edge weight between nodes κ and ν , w να represents the edge weight between nodes α and ν , w κα represents the edge weight between nodes κ and α.
where P C (ν) is expressed as where ν denotes the ν-th eigenvalue of the adjacency matrix(single-layer network).
It can be seen from Table 1 that 93.75% of p-value values are less than 0.001, and 100% of p-value values are less than 0.05. Figure 2 shows two randomly selected 8-layer brain networks. One sub-graph corresponds to one layer of the MMBN and is related to a specific frequency band. The MMBN in the normal state is located in the upper row, and the MMBN in the seizure state is located in the lower row. As can be seen, the network topology shows obvious differences in different frequency bands. All the above indicates that the proposed multilayer Table 1. p-value of MMBN statistical measure between normal state and seizure state ( * : p < 0.05, * * : p < 0.001).

Sub_1
Sub_2 www.nature.com/scientificreports/ brain network can effectively characterize the differences in the topology of brain networks between seizure and normal, and confirms the importance of frequency and electrodes (channels) in epilepsy detection research.
Attention mechanism-based epilepsy detection. Taking MMBN that integrates spatiotemporal features across eight frequency bands as input, the AM-CNN model was trained using Keras through a fully supervised process and used to perform epilepsy detection on 18 selected subjects. The final results indicated that the epilepsy detection scheme combining multilayer brain network and AM-CNN model can effectively distinguish between normal state and epileptic state, with a classification accuracy of 99.75% sensitivity of 99.43%, and specificity of 99.83%. Some existing research results on the CHB-MIT dataset are also listed in Table 2. The proposed method is better than them in terms of accuracy and sensitivity, and is extremely close to Dang's work in terms of specificity but superior to other works. All of these provide new ideas for the characterization of EEG signals, and also provide technical support for the construction of an efficient and accurate epileptic state detection system.

Discussions
Effectiveness of MMBN. The proposed method in this paper achieves an excellent epilepsy detection performance with an average accuracy of 99.75%. This reflects the overall effectiveness of using multilayer brain networks as new feature inputs. At the same time, we also analyze the effectiveness and contribution of each frequency band to epilepsy detection. Specifically, taking a single-layer network as input, epilepsy detection is performed on 18 subjects using the same AM-CNN architecture. The results are shown in Fig. 3. The average detection accuracy ranges from 79.06% to 92.97%. This indicates that all eight frequency bands divided in this study are helpful for epilepsy detection, but the contribution of each frequency band is different. Meanwhile, the contributions of each frequency band are also influenced by individual differences among the subjects. Taking frequency band F 4,3 4 as an example, the detection results of different subjects fluctuate between 70.9% and 94.2%. www.nature.com/scientificreports/ This further confirms that brain function has multi-frequency characteristics, and MMBN fused with information from multiple frequency bands can more effectively decode epileptic brain states.
Effect of attention mechanism. In the methods section, AM-CNN architecture is designed to conduct feature extraction from multilayer brain networks. To further emphasize and illustrate the role of attention mechanism, we construct a comparison model to validate the effectiveness of the attention mechanism using the same inputs. The architecture and test results of comparative model is shown in Table 3. The performance of comparative model with accuracy of 93.54%, sensitivity of 93.18%, and specificity of 92.76% is significantly lower than those of AM-CNN. The complete AM-CNN does achieve the better performance. This indicates that attention mechanisms play a crucial role in enhancing feature extraction processes in this study.

Rationality of frequency band division.
In order to further prove the rationality of frequency band division in this study, we provide classification results of no band division, two bands ( F 2,0 p,2 (0-32 Hz), F 2,1 p,2 (32-64 Hz)), four bands ( F 3,0 p,3 (0-16 Hz), F 3,1 p,3 (16-32 Hz), F 3,2 p,3 (32-48 Hz), F 3,3 p,3 (48-64 Hz)) and eight bands. The relevant results are shown in Fig. 4. As can be seen, the average detection accuracy of multiple frequency bands exceeds 90%. Especially for eight frequency bands, the accuracy reaches 99.75%. It is worth mentioning that when no band division is performed, the classification accuracy is only 82.16%. This is because features in different frequency bands cannot be used specifically, resulting in information confusion. In summary, considering multiple frequency bands, the proposed method achieves excellent results in epilepsy detection and is expected to provide valuable reference for other EEG-based neurological disease detection.

Experiment validation. Taking the designed MMBN as input, the proposed AM-CNN model is trained
and tested on the CHB-MIT dataset which was created and provided by Boston Children's Hospital (CHB) and the Massachusetts Institute of Technology (MIT) and included 24 subjects (5 males, 3-22 years old; 19 females, 1.5-19 years old).
All scalp electroencephalograms in the CHB-MIT dataset were collected using the international 10-20 system electrode placement method. The electrode positions used in the dataset were FP1, FP2, F7, F3, FZ, F4, F8, FT9, FT10, T7, C3, CZ, C4, T8, P7, P3, PZ, P4, P8, O1, O2, and the sampling frequency was 256 Hz. The dataset adopts a bipolar measurement method, where the collected EEG signals are recorded in the form of voltage differences between adjacent electrodes in a longitudinal direction. The number of electrode pairs (channels) contained in different subsets and different signal segments in the same subset varies from 18 to 23. In this paper, considering data integrity, we used 18 subjects, all of whom had 23 channels of EEG signals (involving frontal lobe: F3, F4, F7, F8, FZ; frontal lobe: FP1, FP2; temporal lobe: T7, T8; occipital lobe: O1, O2; parietal lobe: P3, P4, P7, P8; central lobe: C3, C4, CZ; ft9, ft10). Samples were segmented using a sliding window with a length of 1 s. The sliding step is 0.5 s. In this paper, we obtained 11,150 samples in total, including 5410 normal state samples and 5740 seizure state samples. Aim to avoid contingency, ten-fold cross validation is conducted. For one fold, 90% Multi-frequency multilayer brain network. We establish a multilayer brain network based on EEG signals to study epilepsy related brain states, where each layer corresponds to a specific frequency band. Taking p-channel EEG signals x p,l L l=1 p = 1, 2, . . . , N , with a length of L as an example, MMBN is constructed as follows. Firstly, we perform 4-layer wavelet packet decomposition on the EEG signals of each channel to obtain sixteen frequency bands. The mathematical expression of wavelet packet decomposition is defined as: where F j,i p,n represents the sub-frequency band after n-layer wavelet packet decomposition of p-channel EEG signal. (j, i) is the node order of wavelet packet tree. h(·) is a low pass filter. g(·) is a high pass filter. m and n are the number of decomposition layers. The bandwidth of each frequency band is f s 2 2 4 = 8 Hz , where f s = 256 Hz means sampling frequency. Due to the fact that the frequency of EEG signals reflecting epileptic brain state is mainly distributed within 70Hz [42][43][44] , this study used eight frequency bands, including F 4,0 p,4 (0-8 Hz), . The selected wavelet base is dbN, which has been proven by existing research to be able to decompose EEG signals and has fast computational speed 45,46 .
Secondly, we use the function wprcoef (·) to reconstruct an approximation to raw EEG signals from selected nodes in the wavelet packet tree T. The signals for the reconstruction of sub-frequency band F 4,i p,n is Finally, in each frequency band, we define brain electrodes (or channels) as network nodes. The weight of edge between nodes κ and ν is determined via the Spearman rank correlation coefficient. The mathematical expression is where rg Through determining the edge between each channel pair (or node pair) via the above method, the network under this frequency band can be obtained. In different frequency bands, the correlation characteristics between channels are significantly different, making it possible to obtain different frequency-dependent brain networks. By repeating the above process at eight frequency bands, a multilayer brain network can be constructed, which has eight layers with N nodes per layer. For each layer, 30% of the edges with larger weights are reserved for subsequent analysis.

Convolutional neural network model based on attention mechanism.
Here, take the obtained multilayer brain network as input, a convolutional neural network model based on attention mechanism (AM-CNN) is carefully designed for epilepsy detection. Figure 5 shows the detailed architecture. Table 4 lists the corresponding parameters.
The AM-CNN model consists of two blocks. The function of the first block is a feature extraction based on the attention mechanism (AM-FE module), which is used to acquire multilayer network features from eight frequency bands. Note that, each layer of the multilayer brain network can be represented as an adjacency matrix, which is a grid like data. Elements at positions (ν, κ) in the adjacency matrix represent weights w ν,κ . The first module has eight branches, and it exactly matches the structure of the multilayer brain network. Each branch shares the same structure. Specifically, each branch is provided with two convolution layers (layer 1 and layer 2). Convolutional layer realizes feature extraction by designing a certain number of convolution kernels, which shows obvious advantages in processing grid-like data, such as the adjacency matrix here. In the following description, Layer 1 is simplified to L1, and others similarly. L1 and L2 can be described by the following formula: Approximate signal  www.nature.com/scientificreports/ where A 0 is the input data (i.e., adjacency matrix), σ 1 k and σ 2 k are k-th output characteristic maps of L1 and L2, respectively. w k and b k represent the weight matrix and deviation term of the k-th convolution kernel, and conv(·) represents convolution operation. In each layer,K = 16 convolution kernels are designed, and the size is set to 3 × 3.
Due to the fact that convolution operations mainly handle local information of features. Directly processing the convolutional output features cannot effectively model the interrelationships between channels in the output features. To address this issue, we introduced channel-based attention mechanism after L2 to exploit the channel dependencies in outputs features σ 2 .
where σ 2 k ∈ R H×W is the feature maps corresponding to the k-th convolutional kernel with the heights of H and widths of W. Specifically, in L3, channel-wise statistic σ 3 = σ 3 1 , σ 3 2 , . . . , σ 3 K is generated by using global average pooling, and the k-th element σ 3 k of σ 3 is defined by  www.nature.com/scientificreports/ where σ 2 k (κ, ν) is an element at the position (ν, κ) . In order to fully capture the dependencies between channels, we introduce two dense layers (L4 and L5) to form a bottleneck structure. The outputs of L5 is where W 1 ∈ R K r ×K and W 2 ∈ R K× K r are the weight matrix of L4 and L5, respectively.r represents the reduction ratio, and the value of r is 2 in this study via trade-off between performance and computational cost. In L6, the output of L5 is used to weight each feature map of L2. The mathematical expression is In general, layers 3-6 constitute attention paths, which can enhance the effective features of L2. L7 is a batch normalization (BN) layer that can mitigate overfitting and accelerate the training process. The implementation of BN is as follows: where θ and π are learnable parameters. In order to ensure the distribution consistency of σ 7 k and σ 6 k , σ 6 k is the normalized input data having the following form: where mean(·) and std(·) represent the expected value and standard deviation of σ 7 k . The task of the second block is the feature fusion, which integrates the network features of multiple frequency bands, and then realizes the detection of epilepsy. Firstly, outputs σ 1 k , σ 2 k and σ 7 k from eight frequency bands are concatenated together (L8). Then, we set a convolution layer (L9) with 32 kernels for feature fusion. The kernel size is 3 × 3 . The 32 feature maps of L9 are learned through another convolution layer (L10), and the kernel size is 1 × 1 . The outputs of L10 are flattened in L11. Finally, all learned features are input into a dense layer (L12) for epilepsy detection, using the softmax activation function.

Data availability
The data that support the findings of this study are openly available in CHB-MIT dataset at https:// physi onet. org/ conte nt/ chbmit/ 1.0. 0/.